package com.ruoyi.web.controller.teaching;


import cn.hutool.core.util.PhoneUtil;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teaching.domain.PlatformEEvent;
import com.ruoyi.teaching.domain.PlatformEEventApply;
import com.ruoyi.teaching.domain.vo.PlatformEEventApplyVO;
import com.ruoyi.teaching.service.PlatformEEventApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王旭
 * @since 2025-03-04
 */
@RestController
@RequestMapping("/platform/eventApply")
@Api(tags = "platform-赛事报名信息管理")
@Validated
public class PlatformEEventApplyController {
    @Autowired
    private PlatformEEventApplyService platformEEventApplyService;

    /**
     * 新增报名信息
     */
    @PostMapping("/addApply")
    @ApiOperation(value = "新增报名信息", notes = "新增报名信息")
    @Log(title = "【新增报名信息】", businessType = BusinessType.INSERT)
    public AjaxResult addApply(@RequestBody @Valid PlatformEEventApplyVO platformEEventApplyVO) {
        String phoneNum = platformEEventApplyVO.getPhoneNum();
        if (!PhoneUtil.isPhone(phoneNum)) {
            return AjaxResult.error("手机号格式不正确");
        }
        return platformEEventApplyService.addApply(platformEEventApplyVO);
    }

    /**
     * 查询某个赛事的报名信息
     */
    @GetMapping("/listApplyByEventId")
    @ApiOperation(value = "查询某个赛事的报名信息", notes = "查询某个赛事的报名信息")
    public AjaxResult listApplyByEventId(Integer pageNum, Integer pageSize, Long eventId, String name, String schoolName, Integer identityType) {
        return platformEEventApplyService.listApplyByEventId(pageNum,pageSize,eventId,name,schoolName,identityType);
    }

    /**
     * 批量删除报名信息
     */
    @DeleteMapping("/deleteBatch")
    @ApiOperation(value = "批量删除报名信息", notes = "批量删除报名信息")
    @Log(title = "【批量删除报名信息】", businessType = BusinessType.DELETE)
    public AjaxResult deleteBatch(Long[] ids) {
        return platformEEventApplyService.deleteBatch(ids);
    }

}

